package com.baseDemo.web.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.annotations.GenericGenerator;
/**
 * 权限数据库持久类
 * @author xianwei
 *
 */
@Entity
@Table(name="t_AuthorityEntity")
public class AuthorityEntity implements Serializable{

	private static final long serialVersionUID = -4758529360977698767L;
	
	private String id;
	private String authorityName;
	private String authorityDescription;
	private String authorityURL;
	
	private String navigationid;
	
	private Set<ToolbarMenuEntity> menus = new HashSet<ToolbarMenuEntity>();
	
	private Set<RoleEntity> roles = new HashSet<RoleEntity>();
	
	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "org.hibernate.id.UUIDGenerator")
	@Column(length = 50)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getAuthorityName() {
		return authorityName;
	}
	@Column(length = 50)
	public void setAuthorityName(String authorityName) {
		this.authorityName = authorityName;
	}

	public String getAuthorityDescription() {
		return authorityDescription;
	}
	@Column(length = 150)
	public void setAuthorityDescription(String authorityDescription) {
		this.authorityDescription = authorityDescription;
	}
	@Column(length = 50)
	public String getNavigationid() {
		return navigationid;
	}

	public void setNavigationid(String navigationid) {
		this.navigationid = navigationid;
	}
	@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, targetEntity=ToolbarMenuEntity.class,fetch=FetchType.LAZY )
	@JoinColumn(name="authorityid") 
	@JsonIgnore
	public Set<ToolbarMenuEntity> getMenus() {
		return menus;
	}

	public void setMenus(Set<ToolbarMenuEntity> menus) {
		this.menus = menus;
	}

	@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE},mappedBy = "authorities",fetch = FetchType.LAZY)
	@JsonIgnore
	public Set<RoleEntity> getRoles() {
		return roles;
	}

	public void setRoles(Set<RoleEntity> roles) {
		this.roles = roles;
	}
	@Column(length = 200)
	public String getAuthorityURL() {
		return authorityURL;
	}

	public void setAuthorityURL(String authorityURL) {
		this.authorityURL = authorityURL;
	}
	
	
	
}
